All Questions
4 questions
3votes
1answer
1kviews
Knock down tall buildings
I'm trying to solve the following problem: As you know Bob likes to destroy the buildings. There are N buildings in a city, ith building has ai floors. Bob can do the following operation. Choose a ...
21votes
3answers
4kviews
Loading military units into ships optimally, using backtracking
I solved the following problem using backtracking: We are given a list of military units, their weight and their (numerical) strength. We have a number of ships with a limited carrying capacity. ...
4votes
3answers
8kviews
Knapsack problem - recursive approach with memoization
This post is based on the 0-1 Knapsack problem. I came across this problem in Assignment #4 of Professor Tim Roughgarden's course Greedy Algorithms, Minimum Spanning Trees, and Dynamic Programming on ...
3votes
1answer
533views
Code for dividing gifts equally
I recently came across this problem: It is Lavanya's birthday and several families have been invited for the birthday party. As is customary, all of them have brought gifts for Lavanya as well ...